package com.rjkj.medicalwaste.viewmodels

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.rjkj.medicalwaste.base.BaseViewModel
import com.rjkj.medicalwaste.bean.PackBean
import com.rjkj.medicalwaste.bean.UserBean
import com.rjkj.medicalwaste.network.response.catchException
import com.rjkj.medicalwaste.network.response.deal
import com.rjkj.medicalwaste.network.response.next
import kotlinx.coroutines.launch
import retrofit2.http.Header
import retrofit2.http.Query

class WaitPackDetailViewModel :BaseViewModel() {
    val packList = MutableLiveData(listOf<PackBean>())
    fun getWaitPackDetail(
        url: String = "",
        deviceSn: String,
        hospitalId: String,
    ) {
        viewModelScope.launch {
            request {
                findPackByHospitalId(
                    url,
                    deviceSn,
                    hospitalId
                )
            }.next {
                if(code==200){
                    packList.value = data
                }else{
                    packList.value = listOf()
                }
            }.catchException {
                packList.value = listOf()
                printStackTrace()
            }
        }
    }
}